package cn.tedu.submarine;

import javax.swing.ImageIcon;

/**
 * 机器人(水雷潜艇)类
 */
public class MineSubmarine extends SeaObject implements EnemyLife {
    private int mineSubmIndex = 0;

    public MineSubmarine() {
        super(116, 83);
    }

    public void move() {
        setX(getX() + getSpeed());
    }

    int msIndex = 0;
    int moIndex = 0;
    int boomIndex = 0;

    public ImageIcon getImage() {//画机器人(潜艇)
        if (isLive()) {
            if (++msIndex % 10 == 0) {
                return Images.minesubm[mineSubmIndex++ % 8];
            } else {
                return Images.minesubm[mineSubmIndex % 8];
            }
        } else{
            if (++moIndex % 10 == 0) {
                boomIndex++;
                if (boomIndex==10){
                    setState(REMOVE);
                    return Images.boommap[boomIndex-1];
                }
                return Images.boommap[boomIndex];
            }else {
                return Images.boommap[boomIndex];
            }
        }
    }

    public Mine shootMine() {
        return new Mine(getX() + getWidth(), getY());
    }

    public int shipGetLife() {
        return 1;
    }
}
